<#ftl output_format="HTML" >
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <title>文件管理 [Sipahi]</title>
        <link rel="shortcut icon" href="<@spring.url '/images/favicon.ico' />" type="image/x-icon">
        <link rel="icon" href="<@spring.url '/images/favicon.ico' />" type="image/x-icon">
        <#include "/css.ftl" />
        <#include "/js.ftl" />
    </head>
    <body>
        <div class="as-block">
            <button id="ok" class="btn btn-sm btn-primary disabled" >确认</button>
            <button id="cancel" class="btn btn-sm btn-default" >取消</button>
        </div>
<#include "browser-common.ftl" />
<script>
'use strict';
$(window).resize(() => windowResized());
$(document).ready(() => {
    windowResized();

    let ok = $('#ok');
    let cancel = $('#cancel');
    ok.click(evt => {
        if (selectedFile) {
            let fileUrl = '../static' + selectedFile;
            window.opener.CKEDITOR.tools.callFunction(${funcNum}, fileUrl);
            window.close();
        }
    });
    cancel.click(evt => window.close());
});
document.addEventListener('DOMContentLoaded', () => {
    $('[data-tooltip]').tooltip({
        title: function() {
            return this.getAttribute('data-tooltip');
        },
        placement: function(et, es) {
            return es.getAttribute('data-tooltip-placement') || 'top';
        },
        html: true,
        template: '<div class="tooltip" role="tooltip"><div class="tooltip-inner" style="text-align:left"></div></div>',
        container: 'body',
        viewport: '#files'
    });
});
let windowResized = function() {
    let wh = window.innerHeight;
    browser.style.height = (wh - browser.offsetTop) + 'px';
    onBrowserSizeChanged(browser.clientWidth, browser.clientHeight);
};
let selectedFile = '';
let selectedFileChanged = function(fn) {
    let ok = $('#ok');
    selectedFile = fn;
    if (selectedFile) {
        removeClass(ok, 'disabled');
    } else {
        addClass(ok, 'disabled');
    }
}
</script>
    </body>
</html>
